from wordcloud import WordCloud
import PIL .Image as image
import numpy as np

filename = "eng/Holmes.txt"
imagename = "melon.jpeg"
savepic = "MeCloud.jpeg"
with open(filename, encoding='gb18030', errors = 'ignore') as fp:
    text = fp.read()
    # print(text)
    mask = np.array(image.open(imagename))
    wordcloud = WordCloud(background_color="white",
        mask=mask
    ).generate(text)
    image_produce = wordcloud.to_image()
    image_produce.show()
    wordcloud.to_file(savepic)